package com.woniuxy.handler;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.woniuxy.pojo.House;
import com.woniuxy.pojo.PageInfo;
import com.woniuxy.service.HouseService;
import lombok.Data;

@Data
@Controller
@RequestMapping("/house")
public class HouseHandler {
	@Resource
	private HouseService houseService;

	// 添加房间
	@RequestMapping("/add")
	@ResponseBody
	public boolean add(House house, String ownerName, String ownerPhone) {
		System.out.println(house);
		System.out.println(ownerName);
		System.out.println(ownerPhone);
		return false;
		// return houseService.add(house, ownerName, ownerPhone);

	}

	// 根据页码查房间
	@RequestMapping("/ShowAllByPage")
	@ResponseBody
    public PageInfo ShowAllByPage(int pageNumber) {
        System.out.println("页码：" + pageNumber);
        PageInfo info = houseService.ShowAllByPage(pageNumber);
        System.out.println(info);
        return info;
	}

	// 根据条件查房间并分页
    @RequestMapping("/select")
    @ResponseBody
	public PageInfo select(House house, int pageNumber, int lesseeState) {
		PageInfo pageInfo = houseService.select(house, pageNumber, lesseeState);
		return pageInfo;
	}

	// 删除房间
    @RequestMapping("/delete")
    @ResponseBody
	public int delete(int house_id) {
		int i = houseService.delete(house_id);
		return i;
	}

	// 展示所有房间
    @RequestMapping("/all")
    @ResponseBody
	public List<House> all() {
		return houseService.all();
	}

    // 展示所有可用房间（未满员）
    @RequestMapping("/Available")
    @ResponseBody
    public List<House> Available() {
        List<House> list = houseService.Available();
        return list;
    }
}
